﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FYP14
{
    public partial class Login : System.Web.UI.Page
    {
        public enum usertype
        {
            Admin = 1,
            Doctor = 2,
            Recep = 3
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            DataTable dt = BAL.GetLogin(txtusername.Value, txtPassword.Value);
            if (dt.Rows.Count == 0)
            {
                Response.Write("<script>alert('Invalid Username / Password');</script>");
                return;
            }
            Session["Login"] = dt;
            if (Convert.ToInt32(dt.Rows[0]["user_role_id"]) == (Int32)usertype.Admin)
            {
                Response.Redirect("Default.aspx");
            }
            else if (Convert.ToInt32(dt.Rows[0]["user_role_id"]) == (Int32)usertype.Doctor)
            {
                Response.Redirect("DoctorDefault.aspx");
            }
            else
                Response.Redirect("ReceptionistDefault.aspx");
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            
        }
    }
}